/*
 * Thin wrapper around the truncate(2) system call.  Should be portable
 * to any modern POSIX system.  If it's not, send me hate mail.
 * 
 * This code is hereby released into the public domain.  Share and Enjoy.
 *  David Terrell <dbt_at_meat.net> 2006.
 *
 */

#include <sys/types.h>

#include <errno.h>

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(int ac, char **av)
{
    off_t offset;
    if (ac != 3)
    {
        fprintf(stderr, "Usage: %s file size\n", av[0]);
        exit(2);
        /* NOTREACHED */
    }
    errno = 0;
    offset = strtoull(av[2], NULL, 0);
    if (errno != 0)
    {
        err(1, "Invalid offset: %s", av[2]);
        /* NOTREACHED */
    }
    if (truncate(av[1], offset) != 0)
    {
        err(1, "Truncate failed");
        /* NOTREACHED */
    }
    return 0;
}
